
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  
<!-- Mirrored from werkzeug.palletsprojects.com/en/1.0.x/test/ by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 15 Sep 2020 06:37:08 GMT -->
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test Utilities &#8212; Werkzeug Documentation (1.0.x)</title>
    <link rel="stylesheet" href="../_static/werkzeug.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../../../assets.readthedocs.org/static/css/badge_only.css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script async="async" type="text/javascript" src="../../../../assets.readthedocs.org/static/javascript/readthedocs-doc-embed.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex/index.html" />
    <link rel="search" title="Search" href="../search/index.html" />
    <link rel="next" title="Debugging Applications" href="../debug/index.html" />
    <link rel="prev" title="Serving WSGI Applications" href="../serving/index.html" />
    <link rel="canonical" href="index.html">
  <script>DOCUMENTATION_OPTIONS.URL_ROOT = '../index.html';</script>
   
  
<!-- RTD Extra Head -->

<!-- 
Always link to the latest version, as canonical.
http://docs.readthedocs.org/en/latest/canonical.html
-->
<link rel="canonical" href="index.html" />

<link rel="stylesheet" href="../../../../assets.readthedocs.org/static/css/readthedocs-doc-embed.css" type="text/css" />

<script type="text/javascript" src="../_static/readthedocs-data.js"></script>

<!-- Add page-specific data, which must exist in the page js, not global -->
<script type="text/javascript">
READTHEDOCS_DATA['page'] = "test"
READTHEDOCS_DATA['source_suffix'] = ".rst"
</script>

<script type="text/javascript" src="../../../../assets.readthedocs.org/static/javascript/readthedocs-analytics.js" async="async"></script>

<!-- end RTD <extrahead> -->
</head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex/index.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex/index.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../debug/index.html" title="Debugging Applications"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../serving/index.html" title="Serving WSGI Applications"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">Werkzeug Documentation (1.0.x)</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-werkzeug.test">
<span id="test-utilities"></span><h1>Test Utilities<a class="headerlink" href="#module-werkzeug.test" title="Permalink to this headline">¶</a></h1>
<p>Quite often you want to unittest your application or just check the output
from an interactive python session.  In theory that is pretty simple because
you can fake a WSGI environment and call the application with a dummy
<cite>start_response</cite> and iterate over the application iterator but there are
argumentably better ways to interact with an application.</p>
<div class="section" id="diving-in">
<h2>Diving In<a class="headerlink" href="#diving-in" title="Permalink to this headline">¶</a></h2>
<p>Werkzeug provides a <cite>Client</cite> object which you can pass a WSGI application (and
optionally a response wrapper) which you can use to send virtual requests to
the application.</p>
<p>A response wrapper is a callable that takes three arguments: the application
iterator, the status and finally a list of headers.  The default response
wrapper returns a tuple.  Because response objects have the same signature,
you can use them as response wrapper, ideally by subclassing them and hooking
in test functionality.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.test</span> <span class="k">import</span> <span class="n">Client</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.testapp</span> <span class="k">import</span> <span class="n">test_app</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">BaseResponse</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">test_app</span><span class="p">,</span> <span class="n">BaseResponse</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span><span class="o">.</span><span class="n">status_code</span>
<span class="go">200</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span><span class="o">.</span><span class="n">headers</span>
<span class="go">Headers([(&#39;Content-Type&#39;, &#39;text/html; charset=utf-8&#39;), (&#39;Content-Length&#39;, &#39;6658&#39;)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">resp</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">b&#39;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&#39;</span>
</pre></div>
</div>
<p>Or without a wrapper defined:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">test_app</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">app_iter</span><span class="p">,</span> <span class="n">status</span><span class="p">,</span> <span class="n">headers</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">status</span>
<span class="go">&#39;200 OK&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">headers</span>
<span class="go">Headers([(&#39;Content-Type&#39;, &#39;text/html; charset=utf-8&#39;), (&#39;Content-Length&#39;, &#39;6658&#39;)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="sa">b</span><span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">app_iter</span><span class="p">)</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">b&#39;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="environment-building">
<h2>Environment Building<a class="headerlink" href="#environment-building" title="Permalink to this headline">¶</a></h2>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><p>The easiest way to interactively test applications is using the
<a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a>.  It can create both standard WSGI environments
and request objects.</p>
<p>The following example creates a WSGI environment with one uploaded file
and a form field:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.test</span> <span class="k">import</span> <span class="n">EnvironBuilder</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">io</span> <span class="k">import</span> <span class="n">BytesIO</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span> <span class="o">=</span> <span class="n">EnvironBuilder</span><span class="p">(</span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;foo&#39;</span><span class="p">:</span> <span class="s1">&#39;this is some text&#39;</span><span class="p">,</span>
<span class="gp">... </span>     <span class="s1">&#39;file&#39;</span><span class="p">:</span> <span class="p">(</span><span class="n">BytesIO</span><span class="p">(</span><span class="s1">&#39;my file contents&#39;</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">&quot;utf8&quot;</span><span class="p">)),</span> <span class="s1">&#39;test.txt&#39;</span><span class="p">)})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">env</span> <span class="o">=</span> <span class="n">builder</span><span class="o">.</span><span class="n">get_environ</span><span class="p">()</span>
</pre></div>
</div>
<p>The resulting environment is a regular WSGI environment that can be used for
further processing:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="k">import</span> <span class="n">Request</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span> <span class="o">=</span> <span class="n">Request</span><span class="p">(</span><span class="n">env</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">form</span><span class="p">[</span><span class="s1">&#39;foo&#39;</span><span class="p">]</span>
<span class="go">&#39;this is some text&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span>
<span class="go">&lt;FileStorage: u&#39;test.txt&#39; (&#39;text/plain&#39;)&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">req</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="s1">&#39;file&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="go">b&#39;my file contents&#39;</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a> figures out the content type automatically if you
pass a dict to the constructor as <cite>data</cite>.  If you provide a string or an
input stream you have to do that yourself.</p>
<p>By default it will try to use <code class="docutils literal notranslate"><span class="pre">application/x-www-form-urlencoded</span></code> and only
use <code class="docutils literal notranslate"><span class="pre">multipart/form-data</span></code> if files are uploaded:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span> <span class="o">=</span> <span class="n">EnvironBuilder</span><span class="p">(</span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;foo&#39;</span><span class="p">:</span> <span class="s1">&#39;bar&#39;</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span>
<span class="go">&#39;application/x-www-form-urlencoded&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="s1">&#39;foo&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">BytesIO</span><span class="p">(</span><span class="s1">&#39;contents&#39;</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">&quot;utf8&quot;</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span>
<span class="go">&#39;multipart/form-data&#39;</span>
</pre></div>
</div>
<p>If a string is provided as data (or an input stream) you have to specify
the content type yourself:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span> <span class="o">=</span> <span class="n">EnvironBuilder</span><span class="p">(</span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;POST&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s1">&#39;{&quot;json&quot;: &quot;this is&quot;}&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">builder</span><span class="o">.</span><span class="n">content_type</span> <span class="o">=</span> <span class="s1">&#39;application/json&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="testing-api">
<h2>Testing API<a class="headerlink" href="#testing-api" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="werkzeug.test.EnvironBuilder">
<em class="property">class </em><code class="descclassname">werkzeug.test.</code><code class="descname">EnvironBuilder</code><span class="sig-paren">(</span><em>path='/'</em>, <em>base_url=None</em>, <em>query_string=None</em>, <em>method='GET'</em>, <em>input_stream=None</em>, <em>content_type=None</em>, <em>content_length=None</em>, <em>errors_stream=None</em>, <em>multithread=False</em>, <em>multiprocess=False</em>, <em>run_once=False</em>, <em>headers=None</em>, <em>data=None</em>, <em>environ_base=None</em>, <em>environ_overrides=None</em>, <em>charset='utf-8'</em>, <em>mimetype=None</em>, <em>json=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder" title="Permalink to this definition">¶</a></dt>
<dd><p>This class can be used to conveniently create a WSGI environment
for testing purposes.  It can be used to quickly create WSGI environments
or request objects from arbitrary data.</p>
<p>The signature of this class is also used in some other places as of
Werkzeug 0.5 (<a class="reference internal" href="#werkzeug.test.create_environ" title="werkzeug.test.create_environ"><code class="xref py py-func docutils literal notranslate"><span class="pre">create_environ()</span></code></a>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseResponse.from_values()</span></code>,
<a class="reference internal" href="#werkzeug.test.Client.open" title="werkzeug.test.Client.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.open()</span></code></a>).  Because of this most of the functionality is
available through the constructor alone.</p>
<p>Files and regular form data can be manipulated independently of each
other with the <a class="reference internal" href="#werkzeug.test.EnvironBuilder.form" title="werkzeug.test.EnvironBuilder.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> and <a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> attributes, but are
passed with the same argument to the constructor: <cite>data</cite>.</p>
<p><cite>data</cite> can be any of these values:</p>
<ul class="simple">
<li>a <cite>str</cite> or <cite>bytes</cite> object: The object is converted into an
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.input_stream" title="werkzeug.test.EnvironBuilder.input_stream"><code class="xref py py-attr docutils literal notranslate"><span class="pre">input_stream</span></code></a>, the <a class="reference internal" href="#werkzeug.test.EnvironBuilder.content_length" title="werkzeug.test.EnvironBuilder.content_length"><code class="xref py py-attr docutils literal notranslate"><span class="pre">content_length</span></code></a> is set and you have to
provide a <a class="reference internal" href="#werkzeug.test.EnvironBuilder.content_type" title="werkzeug.test.EnvironBuilder.content_type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">content_type</span></code></a>.</li>
<li>a <cite>dict</cite> or <code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code>: The keys have to be strings. The values
have to be either any of the following objects, or a list of any of the
following objects:<ul>
<li>a <code class="xref py py-class docutils literal notranslate"><span class="pre">file</span></code>-like object:  These are converted into
<code class="xref py py-class docutils literal notranslate"><span class="pre">FileStorage</span></code> objects automatically.</li>
<li>a <cite>tuple</cite>:  The <code class="xref py py-meth docutils literal notranslate"><span class="pre">add_file()</span></code> method is called
with the key and the unpacked <cite>tuple</cite> items as positional
arguments.</li>
<li>a <cite>str</cite>:  The string is set as form data for the associated key.</li>
</ul>
</li>
<li>a file-like object: The object content is loaded in memory and then
handled like a regular <cite>str</cite> or a <cite>bytes</cite>.</li>
</ul>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>path</strong> – the path of the request.  In the WSGI environment this will
end up as <cite>PATH_INFO</cite>.  If the <cite>query_string</cite> is not defined
and there is a question mark in the <cite>path</cite> everything after
it is used as query string.</li>
<li><strong>base_url</strong> – the base URL is a URL that is used to extract the WSGI
URL scheme, host (server name + server port) and the
script root (<cite>SCRIPT_NAME</cite>).</li>
<li><strong>query_string</strong> – an optional string or dict with URL parameters.</li>
<li><strong>method</strong> – the HTTP method to use, defaults to <cite>GET</cite>.</li>
<li><strong>input_stream</strong> – an optional input stream.  Do not specify this and
<cite>data</cite>.  As soon as an input stream is set you can’t
modify <a class="reference internal" href="#werkzeug.test.EnvironBuilder.args" title="werkzeug.test.EnvironBuilder.args"><code class="xref py py-attr docutils literal notranslate"><span class="pre">args</span></code></a> and <a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> unless you
set the <a class="reference internal" href="#werkzeug.test.EnvironBuilder.input_stream" title="werkzeug.test.EnvironBuilder.input_stream"><code class="xref py py-attr docutils literal notranslate"><span class="pre">input_stream</span></code></a> to <cite>None</cite> again.</li>
<li><strong>content_type</strong> – The content type for the request.  As of 0.5 you
don’t have to provide this when specifying files
and form data via <cite>data</cite>.</li>
<li><strong>content_length</strong> – The content length for the request.  You don’t
have to specify this when providing data via
<cite>data</cite>.</li>
<li><strong>errors_stream</strong> – an optional error stream that is used for
<cite>wsgi.errors</cite>.  Defaults to <code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code>.</li>
<li><strong>multithread</strong> – controls <cite>wsgi.multithread</cite>.  Defaults to <cite>False</cite>.</li>
<li><strong>multiprocess</strong> – controls <cite>wsgi.multiprocess</cite>.  Defaults to <cite>False</cite>.</li>
<li><strong>run_once</strong> – controls <cite>wsgi.run_once</cite>.  Defaults to <cite>False</cite>.</li>
<li><strong>headers</strong> – an optional list or <code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code> object of headers.</li>
<li><strong>data</strong> – a string or dict of form data or a file-object.
See explanation above.</li>
<li><strong>json</strong> – An object to be serialized and assigned to <code class="docutils literal notranslate"><span class="pre">data</span></code>.
Defaults the content type to <code class="docutils literal notranslate"><span class="pre">&quot;application/json&quot;</span></code>.
Serialized with the function assigned to <a class="reference internal" href="#werkzeug.test.EnvironBuilder.json_dumps" title="werkzeug.test.EnvironBuilder.json_dumps"><code class="xref py py-attr docutils literal notranslate"><span class="pre">json_dumps</span></code></a>.</li>
<li><strong>environ_base</strong> – an optional dict of environment defaults.</li>
<li><strong>environ_overrides</strong> – an optional dict of environment overrides.</li>
<li><strong>charset</strong> – the charset used to encode unicode data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.15: </span>The <code class="docutils literal notranslate"><span class="pre">json</span></code> param and <a class="reference internal" href="#werkzeug.test.EnvironBuilder.json_dumps" title="werkzeug.test.EnvironBuilder.json_dumps"><code class="xref py py-meth docutils literal notranslate"><span class="pre">json_dumps()</span></code></a> method.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.15: </span>The environ has keys <code class="docutils literal notranslate"><span class="pre">REQUEST_URI</span></code> and <code class="docutils literal notranslate"><span class="pre">RAW_URI</span></code> containing
the path before perecent-decoding. This is not part of the WSGI
PEP, but many WSGI servers include it.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6: </span><code class="docutils literal notranslate"><span class="pre">path</span></code> and <code class="docutils literal notranslate"><span class="pre">base_url</span></code> can now be unicode strings that are
encoded with <code class="xref py py-func docutils literal notranslate"><span class="pre">iri_to_uri()</span></code>.</p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.path">
<code class="descname">path</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.path" title="Permalink to this definition">¶</a></dt>
<dd><p>The path of the application.  (aka <cite>PATH_INFO</cite>)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.charset">
<code class="descname">charset</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>The charset used to encode unicode data.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code> object with the request headers.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.errors_stream">
<code class="descname">errors_stream</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.errors_stream" title="Permalink to this definition">¶</a></dt>
<dd><p>The error stream used for the <cite>wsgi.errors</cite> stream.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.multithread">
<code class="descname">multithread</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.multithread" title="Permalink to this definition">¶</a></dt>
<dd><p>The value of <cite>wsgi.multithread</cite></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.multiprocess">
<code class="descname">multiprocess</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.multiprocess" title="Permalink to this definition">¶</a></dt>
<dd><p>The value of <cite>wsgi.multiprocess</cite></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.environ_base">
<code class="descname">environ_base</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.environ_base" title="Permalink to this definition">¶</a></dt>
<dd><p>The dict used as base for the newly create environ.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.environ_overrides">
<code class="descname">environ_overrides</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.environ_overrides" title="Permalink to this definition">¶</a></dt>
<dd><p>A dict with values that are used to override the generated environ.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.input_stream">
<code class="descname">input_stream</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.input_stream" title="Permalink to this definition">¶</a></dt>
<dd><p>The optional input stream.  This and <a class="reference internal" href="#werkzeug.test.EnvironBuilder.form" title="werkzeug.test.EnvironBuilder.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> / <a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a>
is mutually exclusive.  Also do not provide this stream if the
request method is not <cite>POST</cite> / <cite>PUT</cite> or something comparable.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.args">
<code class="descname">args</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.args" title="Permalink to this definition">¶</a></dt>
<dd><p>The URL arguments as <code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.base_url">
<code class="descname">base_url</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.base_url" title="Permalink to this definition">¶</a></dt>
<dd><p>The base URL is used to extract the URL scheme, host name,
port, and root path.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.EnvironBuilder.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes all files.  If you put real <code class="xref py py-class docutils literal notranslate"><span class="pre">file</span></code> objects into the
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> dict you can call this method to automatically close
them all in one go.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>The content length as integer.  Reflected from and to the
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.headers" title="werkzeug.test.EnvironBuilder.headers"><code class="xref py py-attr docutils literal notranslate"><span class="pre">headers</span></code></a>.  Do not set if you set <a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> or
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.form" title="werkzeug.test.EnvironBuilder.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> for auto detection.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The content type for the request.  Reflected from and to
the <a class="reference internal" href="#werkzeug.test.EnvironBuilder.headers" title="werkzeug.test.EnvironBuilder.headers"><code class="xref py py-attr docutils literal notranslate"><span class="pre">headers</span></code></a>.  Do not set if you set <a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a> or
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.form" title="werkzeug.test.EnvironBuilder.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> for auto detection.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.files">
<code class="descname">files</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.files" title="Permalink to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">FileMultiDict</span></code> of uploaded files. Use
<code class="xref py py-meth docutils literal notranslate"><span class="pre">add_file()</span></code> to add new files.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.form">
<code class="descname">form</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.form" title="Permalink to this definition">¶</a></dt>
<dd><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code> of form values.</p>
</dd></dl>

<dl class="classmethod">
<dt id="werkzeug.test.EnvironBuilder.from_environ">
<em class="property">classmethod </em><code class="descname">from_environ</code><span class="sig-paren">(</span><em>environ</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.from_environ" title="Permalink to this definition">¶</a></dt>
<dd><p>Turn an environ dict back into a builder. Any extra kwargs
override the args extracted from the environ.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.15.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.test.EnvironBuilder.get_environ">
<code class="descname">get_environ</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.get_environ" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the built environ.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.15: </span>The content type and length headers are set based on
input stream detection. Previously this only set the WSGI
keys.</p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.test.EnvironBuilder.get_request">
<code class="descname">get_request</code><span class="sig-paren">(</span><em>cls=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.get_request" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a request with the data.  If the request class is not
specified <a class="reference internal" href="#werkzeug.test.EnvironBuilder.request_class" title="werkzeug.test.EnvironBuilder.request_class"><code class="xref py py-attr docutils literal notranslate"><span class="pre">request_class</span></code></a> is used.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>cls</strong> – The request wrapper to use.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt>
<code class="descname">input_stream</code></dt>
<dd><p>An optional input stream.  If you set this it will clear
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.form" title="werkzeug.test.EnvironBuilder.form"><code class="xref py py-attr docutils literal notranslate"><span class="pre">form</span></code></a> and <a class="reference internal" href="#werkzeug.test.EnvironBuilder.files" title="werkzeug.test.EnvironBuilder.files"><code class="xref py py-attr docutils literal notranslate"><span class="pre">files</span></code></a>.</p>
</dd></dl>

<dl class="staticmethod">
<dt id="werkzeug.test.EnvironBuilder.json_dumps">
<em class="property">static </em><code class="descname">json_dumps</code><span class="sig-paren">(</span><em>obj</em>, <em>*</em>, <em>skipkeys=False</em>, <em>ensure_ascii=True</em>, <em>check_circular=True</em>, <em>allow_nan=True</em>, <em>cls=None</em>, <em>indent=None</em>, <em>separators=None</em>, <em>default=None</em>, <em>sort_keys=False</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.EnvironBuilder.json_dumps" title="Permalink to this definition">¶</a></dt>
<dd><p>The serialization function used when <code class="docutils literal notranslate"><span class="pre">json</span></code> is passed.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.mimetype">
<code class="descname">mimetype</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype (content type without charset etc.)</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.14.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.mimetype_params">
<code class="descname">mimetype_params</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.mimetype_params" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype parameters as dict.  For example if the
content type is <code class="docutils literal notranslate"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the params would be
<code class="docutils literal notranslate"><span class="pre">{'charset':</span> <span class="pre">'utf-8'}</span></code>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.14.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.query_string">
<code class="descname">query_string</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.query_string" title="Permalink to this definition">¶</a></dt>
<dd><p>The query string.  If you set this to a string
<a class="reference internal" href="#werkzeug.test.EnvironBuilder.args" title="werkzeug.test.EnvironBuilder.args"><code class="xref py py-attr docutils literal notranslate"><span class="pre">args</span></code></a> will no longer be available.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.request_class">
<code class="descname">request_class</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.request_class" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.wrappers.base_request.BaseRequest</span></code></p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.server_name">
<code class="descname">server_name</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.server_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The server name (read-only, use <code class="xref py py-attr docutils literal notranslate"><span class="pre">host</span></code> to set)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.server_port">
<code class="descname">server_port</code><a class="headerlink" href="#werkzeug.test.EnvironBuilder.server_port" title="Permalink to this definition">¶</a></dt>
<dd><p>The server port as integer (read-only, use <code class="xref py py-attr docutils literal notranslate"><span class="pre">host</span></code> to set)</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.server_protocol">
<code class="descname">server_protocol</code><em class="property"> = 'HTTP/1.1'</em><a class="headerlink" href="#werkzeug.test.EnvironBuilder.server_protocol" title="Permalink to this definition">¶</a></dt>
<dd><p>the server protocol to use.  defaults to HTTP/1.1</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.test.EnvironBuilder.wsgi_version">
<code class="descname">wsgi_version</code><em class="property"> = (1, 0)</em><a class="headerlink" href="#werkzeug.test.EnvironBuilder.wsgi_version" title="Permalink to this definition">¶</a></dt>
<dd><p>the wsgi version to use.  defaults to (1, 0)</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.test.Client">
<em class="property">class </em><code class="descclassname">werkzeug.test.</code><code class="descname">Client</code><span class="sig-paren">(</span><em>application</em>, <em>response_wrapper=None</em>, <em>use_cookies=True</em>, <em>allow_subdomain_redirects=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client" title="Permalink to this definition">¶</a></dt>
<dd><p>This class allows you to send requests to a wrapped application.</p>
<p>The response wrapper can be a class or factory function that takes
three arguments: app_iter, status and headers.  The default response
wrapper just returns a tuple.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ClientResponse</span><span class="p">(</span><span class="n">BaseResponse</span><span class="p">):</span>
    <span class="o">...</span>

<span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">MyApplication</span><span class="p">(),</span> <span class="n">response_wrapper</span><span class="o">=</span><span class="n">ClientResponse</span><span class="p">)</span>
</pre></div>
</div>
<p>The use_cookies parameter indicates whether cookies should be stored and
sent for subsequent requests. This is True by default, but passing False
will disable this behaviour.</p>
<p>If you want to request some subdomain of your application you may set
<cite>allow_subdomain_redirects</cite> to <cite>True</cite> as if not no external redirects
are allowed.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.15: </span>The <code class="docutils literal notranslate"><span class="pre">json</span></code> parameter.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.14: </span>The <cite>mimetype</cite> parameter was added.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5: </span><cite>use_cookies</cite> is new in this version.  Older versions did not provide
builtin cookie support.</p>
</div>
</details><dl class="method">
<dt id="werkzeug.test.Client.open">
<code class="descname">open</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes the same arguments as the <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a> class with
some additions:  You can provide a <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a> or a WSGI
environment as only argument instead of the <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a>
arguments and two optional keyword arguments (<cite>as_tuple</cite>, <cite>buffered</cite>)
that change the type of the return value or the way the application is
executed.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>If a dict is provided as file in the dict for the <cite>data</cite> parameter
the content type has to be called <cite>content_type</cite> now instead of
<cite>mimetype</cite>.  This change was made for consistency with
<code class="xref py py-class docutils literal notranslate"><span class="pre">werkzeug.FileWrapper</span></code>.</p>
<blockquote>
<div>The <cite>follow_redirects</cite> parameter was added to <a class="reference internal" href="#werkzeug.test.Client.open" title="werkzeug.test.Client.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a>.</div></blockquote>
</div>
</details><p>Additional parameters:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>as_tuple</strong> – Returns a tuple in the form <code class="docutils literal notranslate"><span class="pre">(environ,</span> <span class="pre">result)</span></code></li>
<li><strong>buffered</strong> – Set this to True to buffer the application run.
This will automatically close the application for
you as well.</li>
<li><strong>follow_redirects</strong> – Set this to True if the <cite>Client</cite> should
follow HTTP redirects.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<p>Shortcut methods are available for many HTTP methods:</p>
<dl class="method">
<dt id="werkzeug.test.Client.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to GET.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.patch">
<code class="descname">patch</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.patch" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to PATCH.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.post">
<code class="descname">post</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.post" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to POST.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.head">
<code class="descname">head</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.head" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to HEAD.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.put">
<code class="descname">put</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.put" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to PUT.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.delete">
<code class="descname">delete</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to DELETE.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.options">
<code class="descname">options</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.options" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to OPTIONS.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.test.Client.trace">
<code class="descname">trace</code><span class="sig-paren">(</span><em>*args</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.Client.trace" title="Permalink to this definition">¶</a></dt>
<dd><p>Like open but method is enforced to TRACE.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="werkzeug.test.create_environ">
<code class="descclassname">werkzeug.test.</code><code class="descname">create_environ</code><span class="sig-paren">(</span><span class="optional">[</span><em>options</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.create_environ" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new WSGI environ dict based on the values passed.  The first
parameter should be the path of the request which defaults to ‘/’.  The
second one can either be an absolute path (in that case the host is
localhost:80) or a full path to the request with scheme, netloc port and
the path to the script.</p>
<p>This accepts the same arguments as the <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a>
constructor.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>This function is now a thin wrapper over <a class="reference internal" href="#werkzeug.test.EnvironBuilder" title="werkzeug.test.EnvironBuilder"><code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code></a> which
was added in 0.5.  The <cite>headers</cite>, <cite>environ_base</cite>, <cite>environ_overrides</cite>
and <cite>charset</cite> parameters were added.</p>
</div>
</details></dd></dl>

<dl class="function">
<dt id="werkzeug.test.run_wsgi_app">
<code class="descclassname">werkzeug.test.</code><code class="descname">run_wsgi_app</code><span class="sig-paren">(</span><em>app</em>, <em>environ</em>, <em>buffered=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.test.run_wsgi_app" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a tuple in the form (app_iter, status, headers) of the
application output.  This works best if you pass it an application that
returns an iterator all the time.</p>
<p>Sometimes applications may use the <cite>write()</cite> callable returned
by the <cite>start_response</cite> function.  This tries to resolve such edge
cases automatically.  But if you don’t get the expected output you
should set <cite>buffered</cite> to <cite>True</cite> which enforces buffering.</p>
<p>If passed an invalid WSGI application the behavior of this function is
undefined.  Never pass non-conforming WSGI applications to this function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>app</strong> – the application to execute.</li>
<li><strong>buffered</strong> – set to <cite>True</cite> to enforce buffering.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple in the form <code class="docutils literal notranslate"><span class="pre">(app_iter,</span> <span class="pre">status,</span> <span class="pre">headers)</span></code></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
  <span id="sidebar-top"></span>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  
    
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/werkzeug.png" alt="Logo"/>
            </a></p>
  

  <h3>Contents</h3>
  <ul>
<li><a class="reference internal" href="#">Test Utilities</a><ul>
<li><a class="reference internal" href="#diving-in">Diving In</a></li>
<li><a class="reference internal" href="#environment-building">Environment Building</a></li>
<li><a class="reference internal" href="#testing-api">Testing API</a></li>
</ul>
</li>
</ul>
<h3>Navigation</h3>
<ul>
  <li><a href="../index.html">Overview</a>
    <ul>
          <li>Previous: <a href="../serving/index.html" title="previous chapter">Serving WSGI Applications</a>
          <li>Next: <a href="../debug/index.html" title="next chapter">Debugging Applications</a>
    </ul>
  </li>
</ul>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://werkzeug.palletsprojects.com/en/1.0.x/search/" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
  
    <div class="footer" role="contentinfo">
        &#169; Copyright 2007 Pallets.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
    </div>
    <script>
      if (typeof READTHEDOCS_DATA !== 'undefined') {
        if (!READTHEDOCS_DATA.features) {
          READTHEDOCS_DATA.features = {};
        }
        READTHEDOCS_DATA.features.docsearch_disabled = true;
      }
    </script>

  </body>

<!-- Mirrored from werkzeug.palletsprojects.com/en/1.0.x/test/ by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 15 Sep 2020 06:37:08 GMT -->
</html>